package com.lora.communication.socket;

import com.lora.dto.EquipmentDto;
import com.lora.entity.EntranceGuard;
import com.lora.service.resolver.EntranceGuardResolver;
import com.lora.util.ApplicationUtil;

import java.util.HashMap;
import java.util.Map;


public class EntranceGuardHeader  {

    public static void main(String[] args) {
        String data="Rec: 07735e1c000000f001000000000000004D27BC9B18010000\r\n" +
                "ReasonNo: 1\r\n" +
                "卡号: 1\r\n" +
                "工号: 1\r\n" +
                "姓名: cs\r\n" +
                "部门: \r\n" +
                "时间: 2019-10-13 19:29:57 星期日\r\n" +
                "地点: m001-1号\r\n" +
                "进出: 出门\r\n" +
                "状态: 刷卡开门\r\n";
        Map<String,String> map=new HashMap<>();
        String[] split = data.split("\r\n");
        for (String s : split) {
            String[] split1 = s.replaceAll(" ","").split(":");
            if(split1.length==2)
                map.put(split1[0],split1[1]);
        }
    }

    public void header(String message){
        String data="Rec: 07735e1c000000f001000000000000004D27BC9B18010000\r\n" +
                "ReasonNo: 1\r\n" +
                "卡号: 1\r\n" +
                "工号: 1\r\n" +
                "姓名: cs\r\n" +
                "部门: \r\n" +
                "时间: 2019-10-13 19:29:57 星期日\r\n" +
                "地点: m001-1号\r\n" +
                "进出: 出门\r\n" +
                "状态: 刷卡开门\r";
        EntranceGuardResolver entranceGuardResolver= ApplicationUtil.getBean("entranceGuardResolver");
        EquipmentDto<EntranceGuard> resolve = entranceGuardResolver.resolve(null, data);
        entranceGuardResolver.save(resolve.getEntity(), false);
    }
}
